/**********************************************************************************
// Asteroids Race 
//
// Creation:	13 Out 2009
// Updated:		18 Apr 2011
// Compiler:	Visual Studio 2010
//
// Notes:		LevelComplete
//
**********************************************************************************/

#include "Asteroids.h"

/**********************************************************************************/

void Asteroids::LevelCompleteLogic()
{
	// Restart Level 
	if (input.KeyPressRelease(DIK_R))
	{
		// exiting sound
		snd.Play(TRANSITION,0);

		// entering level music/sound
		snd.Play(INTRO,1);

		// go to the pre-level state
		gameState = prevState - 1;
	}

	// Next Level 
	if (input.KeyPressRelease(DIK_N))
	{
		// exiting sound
		snd.Play(TRANSITION,0);

		// entering level music/sound
		snd.Play(INTRO,1);

		// go to next level
		gameState = prevState + 1;
	}
}
    
/**********************************************************************************/

void Asteroids::LevelCompleteDraw()
{
	// draw finish marker
	finish.color = finishColor;
	finish.Draw();
 
	// Draw Text
	sprintf_s(text, "LEVEL COMPLETE");
	sysFont->Draw(finPosX-100, finPosY-65, text, Color(0,255,0), 200, 30, DT_CENTER);

	// player time
	sprintf_s(text, "00:%06.3f", playerTime);
	sysFont->Draw(finPosX-100, finPosY-8, text, finishColor, 200, 30, DT_CENTER);

	// record time
	sprintf_s(text, "00:%06.3f", records[prevState/2-1]);
	sysFont->Draw(finPosX-100, finPosY+48, text, Color(0,255,0), 200, 30, DT_CENTER);

	// if player set a new record
	if (playerTime < records[prevState/2-1])
	{
		sprintf_s(text, "New Record");
		sysFont->Draw(finPosX-100, finPosY-32, text, finishColor, 200, 30, DT_CENTER);

		sprintf_s(text, "Previous Record");
		sysFont->Draw(finPosX-100, finPosY+28, text, Color(0,255,0), 200, 30, DT_CENTER);
	}
	else
	{
		sprintf_s(text, "Your Time");
		sysFont->Draw(finPosX-100, finPosY-32, text, finishColor, 200, 30, DT_CENTER);

		sprintf_s(text, "Record");
		sysFont->Draw(finPosX-100, finPosY+28, text, Color(0,255,0), 200, 30, DT_CENTER);
	}

	sprintf_s(text, "<N> - Next level         <R> - Restart level");
	sysFont->Draw(0, GetWindowHeight()-30, text, Color(128,128,128), GetWindowWidth(), 30, DT_CENTER);
 

	
}

/**********************************************************************************/